package Array;

import javax.swing.text.StyledEditorKit;
import java.util.Arrays;
import java.util.Scanner;

public class Exercise {
    /*
    1
    1 1
    1 2 1
    1 3 3 1
    1 4 6 4 1
    1 5 10 10 5 1
    */
    public static void main(String[] args) {
        Scanner sc= new Scanner(System.in);
        System.out.println("请输入行数：");
        int a = sc.nextInt();
        int [][] arr=new int[a][a];
        for (int i = 0; i <arr.length ; i++) {
            arr [i][0] =1;//每一行第一个数都是1
            arr [i][i] =1;//每一列第一个数都是1
        }
        for (int i = 1; i <arr.length ; i++) {//第2行第1个数是它上一行前一列的数+上一行当前列的数
            for (int j = 1; j <=i ; j++) {
                arr[i][j]=arr[i-1][j-1]+arr[i-1][j];
            }
        }
        for (int i = 0; i <arr.length ; i++) {
            for (int j = 0; j <=i ; j++) {
                System.out.print(arr[i][j]+" ");
            }
            System.out.println();
        }
        }
    }

